// Copyright 2025 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Code generated by sidekick. DO NOT EDIT.

#![allow(rustdoc::redundant_explicit_links)]
#![allow(rustdoc::broken_intra_doc_links)]
#![no_implicit_prelude]
extern crate async_trait;
extern crate bytes;
extern crate gax;
extern crate gaxi;
extern crate lazy_static;
extern crate reqwest;
extern crate rpc;
extern crate rpc_context;
extern crate serde;
extern crate serde_json;
extern crate serde_with;
extern crate std;
extern crate tracing;
extern crate wkt;

mod debug;
mod deserialize;
mod serialize;

/// Request message for the Check method.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct CheckRequest {
    /// The service name as specified in its service configuration. For example,
    /// `"pubsub.googleapis.com"`.
    ///
    /// See
    /// [google.api.Service](https://cloud.google.com/service-management/reference/rpc/google.api#google.api.Service)
    /// for the definition of a service name.
    pub service_name: std::string::String,

    /// Specifies the version of the service configuration that should be used to
    /// process the request. Must not be empty. Set this field to 'latest' to
    /// specify using the latest configuration.
    pub service_config_id: std::string::String,

    /// Describes attributes about the operation being executed by the service.
    pub attributes: std::option::Option<rpc_context::model::AttributeContext>,

    /// Describes the resources and the policies applied to each resource.
    pub resources: std::vec::Vec<crate::model::ResourceInfo>,

    /// Optional. Contains a comma-separated list of flags.
    pub flags: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl CheckRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [service_name][crate::model::CheckRequest::service_name].
    pub fn set_service_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.service_name = v.into();
        self
    }

    /// Sets the value of [service_config_id][crate::model::CheckRequest::service_config_id].
    pub fn set_service_config_id<T: std::convert::Into<std::string::String>>(
        mut self,
        v: T,
    ) -> Self {
        self.service_config_id = v.into();
        self
    }

    /// Sets the value of [attributes][crate::model::CheckRequest::attributes].
    pub fn set_attributes<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<rpc_context::model::AttributeContext>,
    {
        self.attributes = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [attributes][crate::model::CheckRequest::attributes].
    pub fn set_or_clear_attributes<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<rpc_context::model::AttributeContext>,
    {
        self.attributes = v.map(|x| x.into());
        self
    }

    /// Sets the value of [resources][crate::model::CheckRequest::resources].
    pub fn set_resources<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::ResourceInfo>,
    {
        use std::iter::Iterator;
        self.resources = v.into_iter().map(|i| i.into()).collect();
        self
    }

    /// Sets the value of [flags][crate::model::CheckRequest::flags].
    pub fn set_flags<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.flags = v.into();
        self
    }
}

impl wkt::message::Message for CheckRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.api.servicecontrol.v2.CheckRequest"
    }
}

/// Describes a resource referenced in the request.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct ResourceInfo {
    /// The name of the resource referenced in the request.
    pub name: std::string::String,

    /// The resource type in the format of "{service}/{kind}".
    pub r#type: std::string::String,

    /// The resource permission needed for this request.
    /// The format must be "{service}/{plural}.{verb}".
    pub permission: std::string::String,

    /// Optional. The identifier of the container of this resource. For Google
    /// Cloud APIs, the resource container must be one of the following formats:
    /// - `projects/<project-id or project-number>`
    ///
    /// - `folders/<folder-number>`
    /// - `organizations/<organization-number>`
    ///
    /// Required for the policy enforcement on the container level (e.g. VPCSC,
    /// Location Policy check, Org Policy check).
    pub container: std::string::String,

    /// Optional. The location of the resource, it must be a valid zone, region or
    /// multiregion, for example: "europe-west4", "northamerica-northeast1-a".
    /// Required for location policy check.
    pub location: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl ResourceInfo {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [name][crate::model::ResourceInfo::name].
    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.name = v.into();
        self
    }

    /// Sets the value of [r#type][crate::model::ResourceInfo::type].
    pub fn set_type<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.r#type = v.into();
        self
    }

    /// Sets the value of [permission][crate::model::ResourceInfo::permission].
    pub fn set_permission<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.permission = v.into();
        self
    }

    /// Sets the value of [container][crate::model::ResourceInfo::container].
    pub fn set_container<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.container = v.into();
        self
    }

    /// Sets the value of [location][crate::model::ResourceInfo::location].
    pub fn set_location<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.location = v.into();
        self
    }
}

impl wkt::message::Message for ResourceInfo {
    fn typename() -> &'static str {
        "type.googleapis.com/google.api.servicecontrol.v2.ResourceInfo"
    }
}

/// Response message for the Check method.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct CheckResponse {
    /// Operation is allowed when this field is not set. Any non-'OK' status
    /// indicates a denial; [google.rpc.Status.details][google.rpc.Status.details]
    /// would contain additional details about the denial.
    ///
    /// [google.rpc.Status.details]: rpc::model::Status::details
    pub status: std::option::Option<rpc::model::Status>,

    /// Returns a set of request contexts generated from the `CheckRequest`.
    pub headers: std::collections::HashMap<std::string::String, std::string::String>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl CheckResponse {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [status][crate::model::CheckResponse::status].
    pub fn set_status<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<rpc::model::Status>,
    {
        self.status = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [status][crate::model::CheckResponse::status].
    pub fn set_or_clear_status<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<rpc::model::Status>,
    {
        self.status = v.map(|x| x.into());
        self
    }

    /// Sets the value of [headers][crate::model::CheckResponse::headers].
    pub fn set_headers<T, K, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = (K, V)>,
        K: std::convert::Into<std::string::String>,
        V: std::convert::Into<std::string::String>,
    {
        use std::iter::Iterator;
        self.headers = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
        self
    }
}

impl wkt::message::Message for CheckResponse {
    fn typename() -> &'static str {
        "type.googleapis.com/google.api.servicecontrol.v2.CheckResponse"
    }
}

/// Request message for the Report method.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct ReportRequest {
    /// The service name as specified in its service configuration. For example,
    /// `"pubsub.googleapis.com"`.
    ///
    /// See
    /// [google.api.Service](https://cloud.google.com/service-management/reference/rpc/google.api#google.api.Service)
    /// for the definition of a service name.
    pub service_name: std::string::String,

    /// Specifies the version of the service configuration that should be used to
    /// process the request. Must not be empty. Set this field to 'latest' to
    /// specify using the latest configuration.
    pub service_config_id: std::string::String,

    /// Describes the list of operations to be reported. Each operation is
    /// represented as an AttributeContext, and contains all attributes around an
    /// API access.
    pub operations: std::vec::Vec<rpc_context::model::AttributeContext>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl ReportRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [service_name][crate::model::ReportRequest::service_name].
    pub fn set_service_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.service_name = v.into();
        self
    }

    /// Sets the value of [service_config_id][crate::model::ReportRequest::service_config_id].
    pub fn set_service_config_id<T: std::convert::Into<std::string::String>>(
        mut self,
        v: T,
    ) -> Self {
        self.service_config_id = v.into();
        self
    }

    /// Sets the value of [operations][crate::model::ReportRequest::operations].
    pub fn set_operations<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<rpc_context::model::AttributeContext>,
    {
        use std::iter::Iterator;
        self.operations = v.into_iter().map(|i| i.into()).collect();
        self
    }
}

impl wkt::message::Message for ReportRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.api.servicecontrol.v2.ReportRequest"
    }
}

/// Response message for the Report method.
/// If the request contains any invalid data, the server returns an RPC error.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct ReportResponse {
    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl ReportResponse {
    pub fn new() -> Self {
        std::default::Default::default()
    }
}

impl wkt::message::Message for ReportResponse {
    fn typename() -> &'static str {
        "type.googleapis.com/google.api.servicecontrol.v2.ReportResponse"
    }
}

/// Message containing resource details in a batch mode.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct ResourceInfoList {
    /// The resource details.
    pub resources: std::vec::Vec<crate::model::ResourceInfo>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl ResourceInfoList {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [resources][crate::model::ResourceInfoList::resources].
    pub fn set_resources<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::ResourceInfo>,
    {
        use std::iter::Iterator;
        self.resources = v.into_iter().map(|i| i.into()).collect();
        self
    }
}

impl wkt::message::Message for ResourceInfoList {
    fn typename() -> &'static str {
        "type.googleapis.com/google.api.servicecontrol.v2.ResourceInfoList"
    }
}
